library(tidyverse)
## ── Attaching packages ─────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.1.0 ✔ purrr 0.3.1
## ✔ tibble 2.0.1 ✔ dplyr 0.8.0.1
## ✔ tidyr 0.8.3 ✔ stringr 1.4.0
## ✔ readr 1.3.1 ✔ forcats 0.4.0
## ── Conflicts ────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(htmlwidgets)
theme_set(theme_bw())
respostas = read_csv(here::here("data/enade-ccc-2017.csv"),
col_types = "cccdccdddc")
pb_pe = respostas %>%
filter(UF %in% c("PB", "PE"))
As bibliotecas que usaremos vêm de http://www.htmlwidgets.org
Veja também esse tutorial
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
p = pb_pe %>%
mutate(texto = str_glue("{IES}\n{enunciado}\n{media}")) %>%
ggplot(aes(x = categoria,
y = media,
color = UF,
label = IES)) +
geom_point(size = 2, alpha = .5) +
coord_flip() +
theme(legend.position = "None")
p
ggplotly(p)
ggplotly(p, tooltip = "label")
plot_ly(data = pb_pe %>% filter(categoria != "Outros"),
x = ~ categoria,
y = ~ media,
# name = "avaliacoes",
type = "scatter",
mode = "markers",
color = ~UF,
text = ~IES)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels